<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('列表')" />
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								模板名称：<input type="text" name="templateName"/>
							</li>


							<li class="select-time">
								<label>绩效时间：</label>
								<input type="text"  class="time-input"   placeholder="开始时间" name="enableStartTime"/>
								<span>-</span>
								<input type="text"  class="time-input"  placeholder="结束时间" name="enableEndTime"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="performance:perTemplate:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="performance:perTemplate:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="performance:perTemplate:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('performance:perTemplate:edit')}]];
        var removeFlag = [[${@permission.hasPermi('performance:perTemplate:remove')}]];
		var configFlag = [[${@permission.hasPermi('performance:perTemplate:config')}]];
		var distributeWeightFlag = [[${@permission.hasPermi('performance:perTemplate:distributeWeight')}]];
        var prefix = ctx + "performance/perTemplate";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'templateId', 
					title : '',
					visible: false
				},
				{
					field : 'templateName', 
					title : '模板名称',
					sortable: true
				},
				{
					field : 'description', 
					title : '描述',
					sortable: true
				},
				{
					field : 'enableStartTime', 
					title : '绩效开始时间',
					sortable: true
				},
				{
					field : 'enableEndTime', 
					title : '绩效结束时间',
					sortable: true
				},

		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.templateId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.templateId + '\')"><i class="fa fa-remove"></i>删除</a>');
						actions.push('<a class="btn btn-success btn-xs ' + configFlag + '" href="#" onclick="configTemplate(\'' + row.templateId + '\')"><i class="fa fa-remove"></i>配置考核项</a>');
						actions.push('<a class="btn btn-info btn-xs ' + distributeWeightFlag + '" href="#" onclick="distributeWeight(\'' + row.templateId + '\')"><i class="fa fa-remove"></i>分配权重</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function configTemplate(templateId){
			var url = prefix+'/config/' + templateId;
			$.modal.openTab("配置考核项", url);
		}
		function distributeWeight(templateId){
			var url = prefix+'/distributeWeight/' + templateId;
			$.modal.open("分配权重", url);
		}
    </script>
</body>
</html>